/* eslint valid-jsdoc: "off" */

'use strict';
const path = require('path');

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1576410063581_1597';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
  //记录日志级别配置，没有在控制台打印，在log日志文件夹中能看到对应的日志收集情况
  config.logger = {
    dir: path.join(appInfo.root, 'logs', appInfo.name),
    encoding: 'utf8',
    env: appInfo.env,
    level: 'INFO',
    consoleLevel: 'INFO',

    outputJSON: false,
    buffer: true,
    appLogName: `${appInfo.name}-web.log`,
    coreLogName: 'egg-web.log',
    agentLogName: 'egg-agent.log',
    errorLogName: 'common-error.log',
    coreLogger: {},
    allowDebugAtProd: false,
  };

  //修改egg默认启动端口
  // config.cluster = {
  //   listen: {
  //     path: '',
  //     port: 8000,
  //     hostname: '0.0.0.0',
  //   }
  // };
  //详细配置参考https://github.com/eggjs/egg-sequelize
  exports.sequelize = {

    dialect: 'mysql',
    host: 'localhost',
    port: 3306,
    database: 'test',
    username: 'root',
    password: '123456',

    define: {
      freezeTableName: true,
      underscored: true,
      timestamps: false,
    },

  };
  return {
    ...config,
    ...userConfig,
  };
};
